#!/bin/sh

tmpdir=/home/john/tmp
svndir=/home/john/src

sites="admin service tt";
party="someparty"

echo -=INSTALLING=-
rm -rf $tmpdir/*
cd $svndir && svn update
cp -R $svndir/* $tmpdir/
cd $tmpdir && find ./ -name .svn -exec rm -rf {} \;
cd $tmpdir

echo -=MAKING GWT=-
for x in `echo $sites`; do
  echo "Makign GWT for $x"
  cd $tmpdir/$x/
  cd $tmpdir/$x/data/gwt_src &&
  for y in `ls`; do
    echo "Making GWT $y for $x"
    cd ./$y
    cp -f $tmpdir/engine/data/gwt_src/servers/servers_lin.java ./src/com/ypaco/client/OSServers.java
    ant -f ./build_lin.xml build || exit 1
    cd ..
    mv ./$y/war/$y $tmpdir/$x/scripts/gwt/
  done || echo "NO GWT"
done
cd $tmpdir

echo -=INSTALLING JENG=-
rm -rf $tmpdir/engine/data
rm -rf $tmpdir/engine/jeng
rm -rf $tmpdir/engine/scripts
rm $tmpdir/engine/config/jeng_config.xml
rm $tmpdir/engine/config/jeng_config_win.xml
mv $tmpdir/engine/config/jeng_config_svr.xml $tmpdir/engine/config/jeng_config.xml
rm -rf /home/jeng/*
mv $tmpdir/engine/* /home/jeng/

echo -=INSTALLING SITES=-
for x in `echo $sites`; do
 echo "Installing $x"
 rm -rf $tmpdir/$x/data
 rm $tmpdir/$x/jeng/jeng.php
 mv $tmpdir/$x/jeng/jeng_svr.php $tmpdir/$x/jeng/jeng.php
 rm -rf /home/$x/www/*
 mv $tmpdir/$x/* /home/$x/www/
done

echo -=INSTALLING 3DPARTY=-
for x in `echo $party`; do
  echo "Installing $x"
  cp -R $svndir/3dparty/$x /home/3dparty/
  cp $svndir/3dparty/$x.php /home/3dparty/
done